@engenty/wizards-runtime 0.14.2 → 0.16.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (263) hide show
  1. package/apps/runtime/dist/agents/studio-assistant.js +180 -4
  2. package/apps/runtime/dist/agents/website.js +10 -5
  3. package/apps/runtime/dist/app.js +27 -2
  4. package/apps/runtime/dist/auth/index.js +5 -0
  5. package/apps/runtime/dist/broker/account.js +5 -0
  6. package/apps/runtime/dist/broker/call.js +2 -0
  7. package/apps/runtime/dist/broker/host.js +1 -0
  8. package/apps/runtime/dist/broker/index.js +5 -0
  9. package/apps/runtime/dist/broker/rwx.js +293 -11
  10. package/apps/runtime/dist/cli/main.js +7 -0
  11. package/apps/runtime/dist/cli/move-files.js +68 -0
  12. package/apps/runtime/dist/cli/move-folder-sources.js +120 -0
  13. package/apps/runtime/dist/connectors/plugin-connections.js +74 -4
  14. package/apps/runtime/dist/db/migrations/tenant/0040_rwx_elements.sql +21 -0
  15. package/apps/runtime/dist/db/migrations/tenant/0041_broker_log_client.sql +1 -0
  16. package/apps/runtime/dist/db/migrations/tenant/0042_client_spaces.sql +16 -0
  17. package/apps/runtime/dist/db/migrations/tenant/0043_space_member_invite.sql +19 -0
  18. package/apps/runtime/dist/db/migrations/tenant/0044_client_portal.sql +8 -0
  19. package/apps/runtime/dist/db/migrations/tenant/0045_client_portal_no_slug.sql +2 -0
  20. package/apps/runtime/dist/db/migrations/tenant/0046_space_file_hash.sql +2 -0
  21. package/apps/runtime/dist/db/migrations/tenant/0047_knowledge_folders.sql +3 -0
  22. package/apps/runtime/dist/db/migrations/tenant/0048_space_chunk_kind.sql +1 -0
  23. package/apps/runtime/dist/db/migrations/tenant/0049_knowledge_sources.sql +57 -0
  24. package/apps/runtime/dist/db/migrations/tenant/0050_dateien.sql +71 -0
  25. package/apps/runtime/dist/db/migrations/tenant/0051_dateien_drafts.sql +23 -0
  26. package/apps/runtime/dist/db/migrations/tenant/0052_dateien_plugin_kinds.sql +5 -0
  27. package/apps/runtime/dist/db/migrations/tenant/0053_dateien_file_title.sql +3 -0
  28. package/apps/runtime/dist/db/migrations/tenant/0054_dateien_ocr.sql +14 -0
  29. package/apps/runtime/dist/db/migrations/tenant/0055_dateien_doc_reread.sql +3 -0
  30. package/apps/runtime/dist/db/migrations/tenant/meta/0040_snapshot.json +5153 -0
  31. package/apps/runtime/dist/db/migrations/tenant/meta/0041_snapshot.json +5160 -0
  32. package/apps/runtime/dist/db/migrations/tenant/meta/0042_snapshot.json +5286 -0
  33. package/apps/runtime/dist/db/migrations/tenant/meta/0043_snapshot.json +5293 -0
  34. package/apps/runtime/dist/db/migrations/tenant/meta/0044_snapshot.json +5344 -0
  35. package/apps/runtime/dist/db/migrations/tenant/meta/0045_snapshot.json +5329 -0
  36. package/apps/runtime/dist/db/migrations/tenant/meta/0046_snapshot.json +5343 -0
  37. package/apps/runtime/dist/db/migrations/tenant/meta/0047_snapshot.json +5391 -0
  38. package/apps/runtime/dist/db/migrations/tenant/meta/0048_snapshot.json +5398 -0
  39. package/apps/runtime/dist/db/migrations/tenant/meta/0049_snapshot.json +5793 -0
  40. package/apps/runtime/dist/db/migrations/tenant/meta/0050_snapshot.json +6288 -0
  41. package/apps/runtime/dist/db/migrations/tenant/meta/0051_snapshot.json +6461 -0
  42. package/apps/runtime/dist/db/migrations/tenant/meta/0052_snapshot.json +6497 -0
  43. package/apps/runtime/dist/db/migrations/tenant/meta/0053_snapshot.json +6504 -0
  44. package/apps/runtime/dist/db/migrations/tenant/meta/0054_snapshot.json +6504 -0
  45. package/apps/runtime/dist/db/migrations/tenant/meta/0055_snapshot.json +6504 -0
  46. package/apps/runtime/dist/db/migrations/tenant/meta/_journal.json +112 -0
  47. package/apps/runtime/dist/db/schema.js +296 -5
  48. package/apps/runtime/dist/docs/dev/api.md +49 -2
  49. package/apps/runtime/dist/docs/dev/architecture.md +13 -2
  50. package/apps/runtime/dist/docs/dev/plugins/connections.md +30 -2
  51. package/apps/runtime/dist/docs/dev/plugins/index.md +1 -1
  52. package/apps/runtime/dist/docs/dev/plugins/reference.md +7 -4
  53. package/apps/runtime/dist/docs/dev/plugins/server.md +11 -5
  54. package/apps/runtime/dist/docs/dev/plugins/space.md +130 -4
  55. package/apps/runtime/dist/docs/dev/plugins/studio.md +13 -3
  56. package/apps/runtime/dist/docs/user-guide/command-line.md +2 -0
  57. package/apps/runtime/dist/docs/user-guide/plugins.md +1 -1
  58. package/apps/runtime/dist/docs/user-guide/space.md +6 -6
  59. package/apps/runtime/dist/docs/user-guide/steps.md +1 -1
  60. package/apps/runtime/dist/documents/ocr.js +72 -0
  61. package/apps/runtime/dist/documents/parse.js +81 -12
  62. package/apps/runtime/dist/elements/caller.js +47 -0
  63. package/apps/runtime/dist/elements/catalogue.js +14 -0
  64. package/apps/runtime/dist/elements/connections.js +60 -0
  65. package/apps/runtime/dist/elements/gate.js +81 -0
  66. package/apps/runtime/dist/elements/knowledge.js +308 -0
  67. package/apps/runtime/dist/elements/outside.js +103 -0
  68. package/apps/runtime/dist/elements/specs.js +102 -0
  69. package/apps/runtime/dist/elements/wizards.js +72 -0
  70. package/apps/runtime/dist/engenty/connections-google/connectors/drive.js +3 -0
  71. package/apps/runtime/dist/engenty/connections-microsoft/onedrive.js +3 -0
  72. package/apps/runtime/dist/engenty/connections-s3/s3.js +6 -0
  73. package/apps/runtime/dist/engine/runner.js +19 -2
  74. package/apps/runtime/dist/engine/steps.js +1 -1
  75. package/apps/runtime/dist/env.js +11 -2
  76. package/apps/runtime/dist/files/blobs.js +57 -1
  77. package/apps/runtime/dist/files/objects.js +1 -0
  78. package/apps/runtime/dist/files/pictures.js +41 -0
  79. package/apps/runtime/dist/files/storage.js +14 -26
  80. package/apps/runtime/dist/files/thumbs.js +77 -0
  81. package/apps/runtime/dist/files/upload-check.js +2 -2
  82. package/apps/runtime/dist/index.js +22 -0
  83. package/apps/runtime/dist/live/views.js +2 -1
  84. package/apps/runtime/dist/manage.js +4 -1
  85. package/apps/runtime/dist/mcp/elements.js +88 -0
  86. package/apps/runtime/dist/mcp/handler.js +2 -0
  87. package/apps/runtime/dist/mcp/scopes.js +5 -0
  88. package/apps/runtime/dist/mcp/tools.js +5 -0
  89. package/apps/runtime/dist/models.js +82 -13
  90. package/apps/runtime/dist/mounts/cache.js +71 -0
  91. package/apps/runtime/dist/mounts/drafts.js +367 -0
  92. package/apps/runtime/dist/mounts/folder.js +148 -0
  93. package/apps/runtime/dist/mounts/mounts.js +1315 -0
  94. package/apps/runtime/dist/mounts/source.js +179 -0
  95. package/apps/runtime/dist/mounts/units.js +97 -0
  96. package/apps/runtime/dist/move-files.js +4 -0
  97. package/apps/runtime/dist/plugins/loader.js +73 -1
  98. package/apps/runtime/dist/plugins/registry.js +2 -0
  99. package/apps/runtime/dist/prompts/authoring.md +2 -2
  100. package/apps/runtime/dist/prompts/goose.md +13 -1
  101. package/apps/runtime/dist/prompts/tools.md +8 -2
  102. package/apps/runtime/dist/render/convert.js +188 -1
  103. package/apps/runtime/dist/routes/api.js +7 -2
  104. package/apps/runtime/dist/routes/client-contract.js +164 -0
  105. package/apps/runtime/dist/routes/client-spaces.js +58 -0
  106. package/apps/runtime/dist/routes/dateien.js +173 -0
  107. package/apps/runtime/dist/routes/elements.js +76 -0
  108. package/apps/runtime/dist/routes/plugins.js +2 -1
  109. package/apps/runtime/dist/routes/runs.js +24 -10
  110. package/apps/runtime/dist/routes/studio.js +168 -8
  111. package/apps/runtime/dist/secrets/signing.js +16 -0
  112. package/apps/runtime/dist/services/client-portal.js +439 -0
  113. package/apps/runtime/dist/services/client-spaces.js +228 -0
  114. package/apps/runtime/dist/services/cloud.js +2 -0
  115. package/apps/runtime/dist/services/knowledge-model.js +24 -8
  116. package/apps/runtime/dist/services/knowledge.js +72 -42
  117. package/apps/runtime/dist/services/links.js +17 -0
  118. package/apps/runtime/dist/services/members-studio.js +5 -1
  119. package/apps/runtime/dist/services/page-pictures.js +162 -0
  120. package/apps/runtime/dist/services/runs.js +22 -6
  121. package/apps/runtime/dist/services/space-categories.js +41 -5
  122. package/apps/runtime/dist/services/space-data.js +165 -8
  123. package/apps/runtime/dist/services/space-files.js +102 -19
  124. package/apps/runtime/dist/services/space-index.js +384 -41
  125. package/apps/runtime/dist/services/space-origin.js +25 -1
  126. package/apps/runtime/dist/services/space-sources.js +937 -0
  127. package/apps/runtime/dist/services/spaces.js +60 -12
  128. package/apps/runtime/dist/services/synced-spaces.js +10 -1
  129. package/apps/runtime/dist/services/work-ai.js +53 -24
  130. package/apps/runtime/dist/services/work-chats.js +3 -2
  131. package/apps/runtime/dist/services/work-connections.js +2 -2
  132. package/apps/runtime/dist/sharing/index.js +2 -0
  133. package/apps/runtime/dist/store/index.js +29 -8
  134. package/apps/runtime/dist/store/shared-lists.js +30 -17
  135. package/apps/runtime/dist/sync/records.js +22 -27
  136. package/apps/runtime/dist/texts.js +4 -0
  137. package/apps/runtime/dist/tools/index.js +5 -4
  138. package/apps/runtime/dist/tools/pages.js +1 -1
  139. package/apps/runtime/dist/tools/skills.js +80 -54
  140. package/apps/runtime/dist/tools/space.js +8 -152
  141. package/apps/runtime/dist/widgets/step.js +2 -1
  142. package/apps/web/dist/assets/AboutDialog-0q4P80yv.js +1 -0
  143. package/apps/web/dist/assets/BlockEditor-CUYFH_CU.js +173 -0
  144. package/apps/web/dist/assets/BlockEditor-CtW6lw0y.css +1 -0
  145. package/apps/web/dist/assets/CapabilitiesPage-BlZP8DYb.js +2 -0
  146. package/apps/web/dist/assets/{ChangelogDialog-D_dQOMIq.js → ChangelogDialog-CDN7kMs1.js} +1 -1
  147. package/apps/web/dist/assets/{CodeEditor-nxoOt8ge.js → CodeEditor-D-Y16fdk.js} +1 -1
  148. package/apps/web/dist/assets/EditorPage-CrMVsgUt.js +3 -0
  149. package/apps/web/dist/assets/{FlowPreview-aMfwcPul.js → FlowPreview-DXnk7m9P.js} +1 -1
  150. package/apps/web/dist/assets/{LangSwitch-DpD0inR4.js → LangSwitch-Dkd0FBIH.js} +1 -1
  151. package/apps/web/dist/assets/Marketplace-Cty40VwG.js +2 -0
  152. package/apps/web/dist/assets/NewWizardChannels-Czool7s1.js +1 -0
  153. package/apps/web/dist/assets/NewWizardPage-CfVe_4a2.js +7 -0
  154. package/apps/web/dist/assets/OnboardingPage-D3SEpTmt.js +1 -0
  155. package/apps/web/dist/assets/PreviewPane-CQDKQO6z.js +7 -0
  156. package/apps/web/dist/assets/PublicRunner-BDZNnlQw.js +1 -0
  157. package/apps/web/dist/assets/ReadOnly-B7MUySpC.js +1 -0
  158. package/apps/web/dist/assets/SettingsPage-Bgurv3l2.js +2 -0
  159. package/apps/web/dist/assets/SetupPage-C3km8vqv.js +1 -0
  160. package/apps/web/dist/assets/{SharePage-N80EhoD7.js → SharePage-UwEJBIzq.js} +1 -1
  161. package/apps/web/dist/assets/SkillEditor-BaEiqqXl.js +1 -0
  162. package/apps/web/dist/assets/Skills-Bv6XbKxc.js +9 -0
  163. package/apps/web/dist/assets/SpacePage-D9PXLSU_.js +2 -0
  164. package/apps/web/dist/assets/UpdateCheck-C7I43zFZ.js +2 -0
  165. package/apps/web/dist/assets/changelog-DwgWiSZb.js +1 -0
  166. package/apps/web/dist/assets/circle-check-DDLzlcXP.js +1 -0
  167. package/apps/web/dist/assets/code-DsnwzN1x.js +1 -0
  168. package/apps/web/dist/assets/code-editor-Ca5EAxmd.js +2 -0
  169. package/apps/web/dist/assets/code-xml-S4IFi5Jc.js +1 -0
  170. package/apps/web/dist/assets/connection-sign-in-hI3HXhq4.js +1 -0
  171. package/apps/web/dist/assets/{dist-H1UN89OA.js → dist-B3Ray2U5.js} +1 -1
  172. package/apps/web/dist/assets/dist-CQpLJoQZ.js +10 -0
  173. package/apps/web/dist/assets/{dist-GlRRx9Xl.js → dist-D1uGQ_tB.js} +1 -1
  174. package/apps/web/dist/assets/{dist-BdDd1FxP.js → dist-DFI-tsfx.js} +1 -1
  175. package/apps/web/dist/assets/eye-TJSuiHHO.js +1 -0
  176. package/apps/web/dist/assets/floating-ui.dom-pwdNGv4b.js +1 -0
  177. package/apps/web/dist/assets/host-D5hNHbhF.js +125 -0
  178. package/apps/web/dist/assets/i18n-BBzMbGoo.js +55 -0
  179. package/apps/web/dist/assets/index-CyBrvupM.js +10 -0
  180. package/apps/web/dist/assets/index-w-3J3ZJ9.css +1 -0
  181. package/apps/web/dist/assets/{json-CEsfHdlZ.js → json-Ce3iHrtf.js} +1 -1
  182. package/apps/web/dist/assets/link-CPL8pB1P.js +1 -0
  183. package/apps/web/dist/assets/list-checks-DaxmUPqK.js +1 -0
  184. package/apps/web/dist/assets/{markdown-5-I9_izp.js → markdown-hqKQy2pp.js} +1 -1
  185. package/apps/web/dist/assets/marked.esm-DQ7XA7AC.js +67 -0
  186. package/apps/web/dist/assets/oss-credits-BrwV0a4F.js +1 -0
  187. package/apps/web/dist/assets/pdf-Dg-raaUo.js +54 -0
  188. package/apps/web/dist/assets/pdf.worker.min-68CMzziE.js +1 -0
  189. package/apps/web/dist/assets/pdf.worker.min-CjEcRF4W.mjs +28 -0
  190. package/apps/web/dist/assets/phone-B4uKDBFq.js +1 -0
  191. package/apps/web/dist/assets/read-aloud-Bfp9_bUY.js +1 -0
  192. package/apps/web/dist/assets/{runners-CyIvJIHr.js → runners-CUpBpSji.js} +1 -1
  193. package/apps/web/dist/assets/scroll-text-BEnPzQEi.js +1 -0
  194. package/apps/web/dist/assets/session-CMQo8P-G.js +2 -0
  195. package/apps/web/dist/assets/table-5B9G3oA6.js +1 -0
  196. package/apps/web/dist/assets/theme-CdX0marK.js +11 -0
  197. package/apps/web/dist/assets/ui-BCfu5sia.js +16 -0
  198. package/apps/web/dist/assets/upload-CAlHC232.js +1 -0
  199. package/apps/web/dist/assets/{useMutation-DEkZhp5c.js → useMutation-1fV4Nnxq.js} +1 -1
  200. package/apps/web/dist/assets/viewers-ChriFcRy.js +2 -0
  201. package/apps/web/dist/assets/volume-2-BqlBtCIJ.js +1 -0
  202. package/apps/web/dist/assets/w3c-keyname-BOAvb0qz.js +1 -0
  203. package/apps/web/dist/assets/xlsx-CuSbHU4R.js +141 -0
  204. package/apps/web/dist/index.html +19 -14
  205. package/apps/web/dist/mcp/flow.html +2 -2
  206. package/node_modules/@engenty/wizards/dist/plugin/index.d.ts +223 -4
  207. package/node_modules/@engenty/wizards/dist/plugin/mount.d.ts +123 -0
  208. package/node_modules/@engenty/wizards/dist/plugin/mount.js +7 -0
  209. package/node_modules/@engenty/wizards/dist/plugin/studio.d.ts +110 -1
  210. package/node_modules/@engenty/wizards-shared/dist/connectors.d.ts +1 -1
  211. package/node_modules/@engenty/wizards-shared/dist/feature-flags.d.ts +24 -0
  212. package/node_modules/@engenty/wizards-shared/dist/feature-flags.js +24 -0
  213. package/node_modules/@engenty/wizards-shared/dist/knowledge.d.ts +33 -4
  214. package/node_modules/@engenty/wizards-shared/dist/run.d.ts +6 -0
  215. package/node_modules/@engenty/wizards-shared/dist/run.js +12 -0
  216. package/node_modules/@engenty/wizards-shared/dist/rwx.d.ts +21 -4
  217. package/node_modules/@engenty/wizards-shared/dist/rwx.js +30 -3
  218. package/node_modules/@engenty/wizards-shared/dist/spaces.d.ts +11 -1
  219. package/node_modules/@engenty/wizards-shared/dist/spaces.js +9 -2
  220. package/node_modules/@engenty/wizards-shared/dist/text-merge.d.ts +6 -0
  221. package/node_modules/@engenty/wizards-shared/dist/text-merge.js +25 -0
  222. package/package.json +3 -1
  223. package/plugin/.claude-plugin/plugin.json +1 -1
  224. package/plugin/README.md +3 -0
  225. package/plugin/plugin.json +1 -1
  226. package/plugin/skills/work-in-space/SKILL.md +16 -0
  227. package/apps/web/dist/assets/AboutDialog-Cag3RJuT.js +0 -1
  228. package/apps/web/dist/assets/CapabilitiesPage-BQYiN0gT.js +0 -2
  229. package/apps/web/dist/assets/EditorPage-C4_8LsQN.js +0 -3
  230. package/apps/web/dist/assets/Marketplace-CpzD9pNQ.js +0 -2
  231. package/apps/web/dist/assets/NewWizardChannels-CcE3UMVb.js +0 -1
  232. package/apps/web/dist/assets/NewWizardPage-BzN7zrQx.js +0 -7
  233. package/apps/web/dist/assets/OnboardingPage-ztHT01ah.js +0 -1
  234. package/apps/web/dist/assets/PreviewPane-BabMbBZI.js +0 -9
  235. package/apps/web/dist/assets/PublicRunner-D-JmtqCi.js +0 -1
  236. package/apps/web/dist/assets/ReadOnly-GAORKKqV.js +0 -1
  237. package/apps/web/dist/assets/SettingsPage-BKAiYmXl.js +0 -2
  238. package/apps/web/dist/assets/SetupPage-C1EZZHIp.js +0 -1
  239. package/apps/web/dist/assets/SkillEditor-CqQMg2MC.js +0 -1
  240. package/apps/web/dist/assets/Skills-CnhpgoOA.js +0 -9
  241. package/apps/web/dist/assets/SpacePage-CRR8JvV1.js +0 -2
  242. package/apps/web/dist/assets/UpdateCheck-CfXZBQNv.js +0 -2
  243. package/apps/web/dist/assets/changelog-6MqC8Vy8.js +0 -1
  244. package/apps/web/dist/assets/circle-alert-C8Ma-bPY.js +0 -1
  245. package/apps/web/dist/assets/circle-check-Bu9Z3mlJ.js +0 -1
  246. package/apps/web/dist/assets/code-editor-CfTGqOpp.js +0 -2
  247. package/apps/web/dist/assets/code-xml-B4kLFZSj.js +0 -1
  248. package/apps/web/dist/assets/connection-sign-in-B2D0O8W-.js +0 -1
  249. package/apps/web/dist/assets/dist-EBVTpvRr.js +0 -10
  250. package/apps/web/dist/assets/eye-BpoKpIdt.js +0 -1
  251. package/apps/web/dist/assets/host-BlKXX7YK.js +0 -118
  252. package/apps/web/dist/assets/i18n-BJ7Ld6O6.js +0 -55
  253. package/apps/web/dist/assets/index-66tE1oti.js +0 -10
  254. package/apps/web/dist/assets/index-D18DvnxX.css +0 -1
  255. package/apps/web/dist/assets/oss-credits-IdX5bc71.js +0 -1
  256. package/apps/web/dist/assets/phone-Ctvf-Am-.js +0 -1
  257. package/apps/web/dist/assets/read-aloud-Da_RSm2S.js +0 -1
  258. package/apps/web/dist/assets/scroll-text-ChrjRu9Y.js +0 -1
  259. package/apps/web/dist/assets/session-SXPtTWRK.js +0 -2
  260. package/apps/web/dist/assets/theme-Br1S0j5h.js +0 -11
  261. package/apps/web/dist/assets/ui-Uqnx1UpK.js +0 -82
  262. package/apps/web/dist/assets/upload-BchUnQGV.js +0 -1
  263. package/apps/web/dist/assets/volume-2-CU_oy81Z.js +0 -1
@@ -1,6 +1,8 @@
1
1
  import { anthropic } from "@ai-sdk/anthropic";
2
2
  import { CONFIRM_ACTION_TOOL } from "@engenty/wizards-shared/assistant";
3
3
  import { textClassOf } from "@engenty/wizards-shared/definition";
4
+ import { RWX_ALL } from "@engenty/wizards-shared/rwx";
5
+ import { SPACE_DATA_LIMITS } from "@engenty/wizards-shared/space-data";
4
6
  import { cleanAssetSections, cleanLogoSections, FACT_TYPES, FONT_USES, factKey, gradientCss, parseGradient, RULE_MARKS, SPACE_FILE_KINDS, SPACE_LIMITS, textStyleLine, } from "@engenty/wizards-shared/spaces";
5
7
  import { pickedClass } from "@engenty/wizards-shared/tiers";
6
8
  import { createTool } from "@mastra/core/tools";
@@ -8,22 +10,27 @@ import { nanoid } from "nanoid";
8
10
  import { z } from "zod";
9
11
  import { knowsTools } from "../assistant/knows.js";
10
12
  import { subjectsOfGoose } from "../broker/rwx.js";
13
+ import { gooseCaller } from "../elements/caller.js";
14
+ import { elementTools } from "../elements/catalogue.js";
15
+ import { brokered, elementCall } from "../elements/gate.js";
11
16
  import { currentFeatures } from "../features.js";
12
17
  import { managed } from "../manage.js";
13
18
  import { chatModel, contextWindowOf, costOf, currentTier, gatewayTools, searchAllowed, textModel, totalUsage, usageOf, } from "../models.js";
19
+ import { mountsOf } from "../mounts/source.js";
14
20
  import { prompt } from "../prompts.js";
15
21
  import { contentPolicy } from "../safety.js";
16
- import { knowledgeCounts } from "../services/knowledge.js";
22
+ import { knowledgeCounts, pageTree, resolvePath } from "../services/knowledge.js";
17
23
  import { activeSkills, skillList } from "../services/skills.js";
18
24
  import { categoryRows } from "../services/space-categories.js";
25
+ import { createPage, updatePage } from "../services/space-data.js";
19
26
  import { addSpaceFileFromUrl, spaceFileContent, spaceFiles, updateSpaceFile, } from "../services/space-files.js";
20
27
  import { documentText } from "../services/space-index.js";
28
+ import { CORE, kindsOf, listSources, proposeSource, takeSource, } from "../services/space-sources.js";
21
29
  import { ownedSpace, updateSpace } from "../services/spaces.js";
22
30
  import { currentTenant } from "../tenants/tenant.js";
23
31
  import { serverText } from "../texts.js";
24
32
  import { assistantPageOf, assistantToolsOf } from "../tools/plugin.js";
25
33
  import { attempt as attemptTool, imageOutput } from "../tools/shared.js";
26
- import { skillToolsOf } from "../tools/skills.js";
27
34
  import { gooseConnectionTools } from "./goose-connections.js";
28
35
  import { spaceAgent } from "./space-agent.js";
29
36
  import { chatTurnWay } from "./subscription.js";
@@ -62,6 +69,7 @@ const LABELS = {
62
69
  set_profile: "doingSetProfile",
63
70
  set_facts: "doingSetFacts",
64
71
  set_colors: "doingSetColors",
72
+ write_knowledge_page: "doingWriteKnowledgePage",
65
73
  look_at_file: "doingLookAtFile",
66
74
  describe_file: "doingDescribeFile",
67
75
  web_search: "doingWebSearch",
@@ -198,6 +206,21 @@ export function gooseSpaceTools(input, space, wrote, on) {
198
206
  turn = next.catch(() => undefined);
199
207
  return next;
200
208
  };
209
+ const caller = gooseCaller({
210
+ space: { id: spaceId, name: space.name },
211
+ userId,
212
+ role: input.user.role,
213
+ signal: signal ?? new AbortController().signal,
214
+ chatId: input.chat?.id,
215
+ });
216
+ /** A page of the space's own Knowledge by its path; an error the model can read where there is none. */
217
+ const pageAt = async (path) => {
218
+ const found = await resolvePath(spaceId, path);
219
+ if (found?.kind !== "page") {
220
+ throw new Error(`There is no page "${path}" in Knowledge. space_list gives the paths.`);
221
+ }
222
+ return found;
223
+ };
201
224
  const tools = {
202
225
  read_website: createTool({
203
226
  id: "read_website",
@@ -561,6 +584,54 @@ export function gooseSpaceTools(input, space, wrote, on) {
561
584
  return { ok: true };
562
585
  }),
563
586
  }),
587
+ // Knowledge's own pages, as a person writes them in the studio: `w` on the page, or on every
588
+ // page for a new one.
589
+ write_knowledge_page: createTool({
590
+ id: "write_knowledge_page",
591
+ description: prompt("goose", "tool.write_knowledge_page"),
592
+ inputSchema: z.object({
593
+ title: z.string().min(1).max(200),
594
+ markdown: z.string().max(SPACE_DATA_LIMITS.pageChars),
595
+ path: z
596
+ .string()
597
+ .max(600)
598
+ .optional()
599
+ .describe("An existing page to replace (pages/…); left out, a new page"),
600
+ parent: z
601
+ .string()
602
+ .max(600)
603
+ .optional()
604
+ .describe("The page it stands under (pages/…); left out, a page of its own"),
605
+ }),
606
+ execute: (args) => attempt(async () => {
607
+ doing("write_knowledge_page");
608
+ const at = args.path ? await pageAt(args.path) : null;
609
+ const parent = args.parent ? await pageAt(args.parent) : null;
610
+ const id = await elementCall(caller, {
611
+ action: "write_knowledge_page",
612
+ resource: { kind: "page", id: at?.id ?? RWX_ALL },
613
+ perm: "w",
614
+ input: args,
615
+ }, async () => {
616
+ if (at) {
617
+ await updatePage(userId, at.id, {
618
+ title: args.title,
619
+ markdown: args.markdown,
620
+ ...(parent ? { parentId: parent.id } : {}),
621
+ });
622
+ return at.id;
623
+ }
624
+ const made = await createPage(userId, spaceId, {
625
+ title: args.title,
626
+ markdown: args.markdown,
627
+ parentId: parent?.id ?? null,
628
+ });
629
+ return made.id;
630
+ });
631
+ wrote();
632
+ return { ok: true, path: (await pageTree(spaceId)).get(id)?.path ?? "" };
633
+ }),
634
+ }),
564
635
  look_at_file: createTool({
565
636
  id: "look_at_file",
566
637
  description: prompt("goose", "tool.look_at_file"),
@@ -601,8 +672,34 @@ export function gooseSpaceTools(input, space, wrote, on) {
601
672
  if (!on.typography) {
602
673
  delete tools.set_typography;
603
674
  }
675
+ // Every write to the space's setup is the broker's: `w` on it, for Goose for its person
676
+ // (docs/plans/modular.md, B4). An admin's deny for Goose stops it; each write is a log line.
677
+ for (const name of SETUP_WRITES) {
678
+ if (tools[name]) {
679
+ tools[name] = brokered(tools[name], caller, (args) => ({
680
+ action: name,
681
+ resource: { kind: "setup", id: spaceId },
682
+ perm: "w",
683
+ input: args,
684
+ }));
685
+ }
686
+ }
604
687
  return tools;
605
688
  }
689
+ /** Goose's tools that write the space's setup: its profile, facts, brand, rules and files. */
690
+ const SETUP_WRITES = [
691
+ "set_profile",
692
+ "set_facts",
693
+ "remove_facts",
694
+ "set_colors",
695
+ "set_logo_sections",
696
+ "set_asset_sections",
697
+ "set_typography",
698
+ "set_gradients",
699
+ "set_rules",
700
+ "save_file",
701
+ "describe_file",
702
+ ];
606
703
  /** A browser tool as the model calls it: sent to the page, its answer awaited. */
607
704
  function browserTool(input, spec) {
608
705
  let inputSchema;
@@ -773,14 +870,93 @@ export async function runStudioAssistant(input) {
773
870
  },
774
871
  }));
775
872
  }
873
+ // Sources of Knowledge, when a plugin brings a kind of them: proposed on a card, taken on it.
874
+ const sourceKinds = writable ? await kindsOf() : [];
875
+ if (writable && sourceKinds.length) {
876
+ // „Aus Dateien übernehmen“: the folders Goose may name are the space's mounts.
877
+ const mounted = sourceKinds.some((k) => k.plugin === CORE && k.source.kind === "dateien")
878
+ ? await mountsOf(writable.id)
879
+ : [];
880
+ const card = (data) => {
881
+ const record = { plugin: "", tool: "sourceProposal", data };
882
+ cards.push(record);
883
+ input.onCard?.(record);
884
+ };
885
+ const sourceSignal = input.signal ?? new AbortController().signal;
886
+ Object.assign(tools, {
887
+ propose_source: createTool({
888
+ id: "propose_source",
889
+ description: [
890
+ prompt("goose", "tool.propose_source"),
891
+ ...(mounted.length
892
+ ? [
893
+ `Mounted in Dateien: ${mounted.map((m) => `dateien/${m.slug} (${m.name})`).join(", ")}.`,
894
+ ]
895
+ : []),
896
+ ].join("\n"),
897
+ inputSchema: z.object({
898
+ address: z
899
+ .string()
900
+ .describe("The website's address, the sitemap's, or a folder's path in Dateien"),
901
+ label: z.string().optional().describe("What the person calls the source, if they said"),
902
+ }),
903
+ execute: (args) => attempt(async () => {
904
+ const proposal = await proposeSource(writable.id, args, {
905
+ signal: sourceSignal,
906
+ emit: (message) => input.onActivity?.(message),
907
+ });
908
+ card(proposal);
909
+ return proposal;
910
+ }),
911
+ }),
912
+ take_source: createTool({
913
+ id: "take_source",
914
+ description: prompt("goose", "tool.take_source"),
915
+ inputSchema: z.object({ id: z.string().describe("The proposal's id") }),
916
+ execute: ({ id }) => attempt(async () => {
917
+ const taken = await takeSource(writable.id, id);
918
+ wrote();
919
+ return { ...taken, running: true };
920
+ }),
921
+ }),
922
+ list_sources: createTool({
923
+ id: "list_sources",
924
+ description: prompt("goose", "tool.list_sources"),
925
+ inputSchema: z.object({}),
926
+ execute: () => attempt(async () => (await listSources(writable.id)).sources.map((s) => ({
927
+ id: s.id,
928
+ label: s.label,
929
+ kind: s.kind,
930
+ address: s.address,
931
+ state: s.state,
932
+ entries: s.counts.included,
933
+ written: s.counts.done,
934
+ toCheck: s.counts.check,
935
+ status: s.status,
936
+ }))),
937
+ }),
938
+ });
939
+ }
776
940
  // The person's own sign-ins to the spaces' connections (goose-connections.ts): reads run, a
777
941
  // write asks them on a card. Never a connection that signs in as the space.
778
942
  Object.assign(tools, await gooseConnectionTools(input));
779
943
  // The space's skills (docs/plans/skills.md): Goose reads them as a step does.
780
944
  const skills = space && switches.skills === true ? await activeSkills(space.id) : null;
781
945
  const allSkills = space && switches.skills === true ? await skillList(space.id) : [];
782
- if (skills) {
783
- Object.assign(tools, skillToolsOf(skills, (name) => input.onActivity?.(serverText(input.lang, "doingReadSkill", { name }))));
946
+ // The space's Knowledge and skills from the tool catalogue (elements/), as Goose for its person.
947
+ if (space) {
948
+ Object.assign(tools, await elementTools(gooseCaller({
949
+ space: { id: space.id, name: space.name },
950
+ userId: input.user.id,
951
+ role: input.user.role,
952
+ signal: input.signal ?? new AbortController().signal,
953
+ chatId: input.chat.id,
954
+ note: (note) => {
955
+ if (note.code === "readsSkill") {
956
+ input.onActivity?.(serverText(input.lang, "doingReadSkill", { name: String(note.params?.name ?? "") }));
957
+ }
958
+ },
959
+ }), { knowledge: true, skills }));
784
960
  }
785
961
  for (const spec of input.browserTools) {
786
962
  // The confirm card is the runtime's to show, never the model's to call.
@@ -1,6 +1,6 @@
1
1
  import { FONT_WEIGHTS } from "@engenty/wizards-shared/spaces";
2
2
  import { webContext } from "../render/chromium.js";
3
- import { htmlToMarkdown } from "../render/convert.js";
3
+ import { absolutePictures, htmlToContent, htmlToMarkdown, picturesOf } from "../render/convert.js";
4
4
  import { safeFetch } from "../tools/net-guard.js";
5
5
  const UA = { "user-agent": "Mozilla/5.0 (compatible; engenty-wizards/0.1)" };
6
6
  const attr = (tag, name) => tag
@@ -327,9 +327,9 @@ export function jsonLdOf(html) {
327
327
  return out.slice(0, 50);
328
328
  }
329
329
  /**
330
- * A page for a plugin (`server.web.read`): its whole text as Markdown, every link and its
331
- * structured data, as against `readWebsite`, which picks what the assistant needs of a
332
- * company's site.
330
+ * A page for a plugin (`server.web.read`): its whole text and its content as Markdown, every
331
+ * link and its structured data, as against `readWebsite`, which picks what the assistant needs
332
+ * of a company's site.
333
333
  */
334
334
  export async function readPage(raw, signal) {
335
335
  const { res, base, html } = await loadPage(raw, signal);
@@ -340,6 +340,9 @@ export async function readPage(raw, signal) {
340
340
  links.push({ url, text: linkText(m[2]) });
341
341
  }
342
342
  }
343
+ // Text and content show the same pictures at the same addresses as `images` names them.
344
+ const pictured = absolutePictures(html, base);
345
+ const content = htmlToContent(pictured).slice(0, 400_000);
343
346
  return {
344
347
  url: base,
345
348
  status: res.status,
@@ -347,7 +350,9 @@ export async function readPage(raw, signal) {
347
350
  lastModified: res.headers.get("last-modified"),
348
351
  title: titleOf(html),
349
352
  description: metaOf(html, "description") || metaOf(html, "og:description"),
350
- text: htmlToMarkdown(html).slice(0, 400_000),
353
+ text: htmlToMarkdown(pictured).slice(0, 400_000),
354
+ content,
355
+ images: picturesOf(content),
351
356
  links,
352
357
  jsonld: jsonLdOf(html),
353
358
  };
@@ -26,9 +26,13 @@ import { openCommand } from "./open-command.js";
26
26
  import { PLUGIN_NAME, pluginArchive, pluginMarketplace } from "./plugin.js";
27
27
  import { apiRoutes } from "./routes/api.js";
28
28
  import { brokerRoutes } from "./routes/broker.js";
29
+ import { clientContractRoutes } from "./routes/client-contract.js";
30
+ import { clientSpaceRoutes } from "./routes/client-spaces.js";
29
31
  import { connectionRoutes } from "./routes/connections.js";
32
+ import { dateienRoutes } from "./routes/dateien.js";
30
33
  import { browserReport, localDebugRoutes } from "./routes/debug.js";
31
34
  import { discoverRoutes } from "./routes/discover.js";
35
+ import { elementRoutes } from "./routes/elements.js";
32
36
  import { internalRoutes } from "./routes/internal.js";
33
37
  import { notFoundAnswer, requestLang, say, spelledFor } from "./routes/lang.js";
34
38
  import { liveRoutes } from "./routes/live.js";
@@ -188,7 +192,7 @@ app.get("/api/config", (c) => c.json({
188
192
  /** The run page asks for feedback at the end and sends bug reports: they reach the Manage-App. */
189
193
  reports: managed,
190
194
  }));
191
- if (serves.studio) {
195
+ if (serves.api) {
192
196
  // OAuth discovery for MCP clients (RFC 9728): the Manage-App is the authorization server.
193
197
  app.get("/.well-known/oauth-protected-resource/*", async (c) => {
194
198
  if (!managed) {
@@ -202,6 +206,8 @@ if (serves.studio) {
202
206
  bearer_methods_supported: ["header"],
203
207
  });
204
208
  });
209
+ }
210
+ if (serves.studio) {
205
211
  // OpenAI's plugin portal checks that the submitter controls the MCP server's host.
206
212
  app.get("/.well-known/openai-apps-challenge", (c) => env.openaiAppsChallenge ? c.text(env.openaiAppsChallenge) : c.notFound());
207
213
  }
@@ -239,6 +245,8 @@ if (serves.doors) {
239
245
  ]);
240
246
  });
241
247
  }
248
+ /** What a client of the organization may ask the studio's routes for: who they are, their client spaces. */
249
+ const CLIENT_OPEN = /\/api\/studio\/(me|spaces)$/;
242
250
  /** The studio's requests that open an item: a wizard, a page, a table, a skill, a space. */
243
251
  const STUDIO_LOADS = /\/api\/studio\/(wizards\/[^/]+|pages\/[^/]+|tables\/[^/]+|skills\/[^/]+|spaces(\/[^/]+(\/(data|knowledge|files|wizards|page|skills))?)?)$/;
244
252
  if (serves.studio) {
@@ -291,8 +299,24 @@ if (serves.studio) {
291
299
  });
292
300
  // A member reaches a space's studio only where its admins opened it (behind `capabilities`).
293
301
  app.use("/api/studio/*", membersStudioGate);
302
+ // A client of the organization reaches no Studio and no Work (docs/plans/client-spaces.md):
303
+ // who they are and their own client spaces, until the client portal brings its own routes.
304
+ app.use("/api/studio/*", async (c, next) => {
305
+ const user = c.get("user");
306
+ if (user?.role !== "client" || (c.req.method === "GET" && CLIENT_OPEN.test(c.req.path))) {
307
+ return next();
308
+ }
309
+ return c.json({ error: say(c, "clientsNotHere"), code: "forbidden" }, 403);
310
+ });
311
+ }
312
+ if (serves.api) {
313
+ // Outside clients: MCP and the API (docs/plans/modular.md), the space's elements among them.
294
314
  const mcp = mcpHandler();
295
315
  app.on(["GET", "POST", "DELETE"], "/api/mcp", (c) => mcp(c.req.raw));
316
+ app.route("/api/v1", elementRoutes);
317
+ // The client contract: a client's own client spaces, for the client portal.
318
+ app.route("/api/v1", clientContractRoutes);
319
+ app.route("/api/v1", apiRoutes);
296
320
  }
297
321
  if (serves.runner) {
298
322
  // The tools of one model call, for the installed Claude Code while it answers that call: the
@@ -322,12 +346,13 @@ if (serves.studio) {
322
346
  app.route("/api/studio", skillRoutes);
323
347
  app.route("/api/studio", discoverRoutes);
324
348
  app.route("/api/studio", ruleRoutes);
349
+ app.route("/api/studio", clientSpaceRoutes);
325
350
  app.route("/api/studio", connectionRoutes);
326
351
  app.route("/api/studio", brokerRoutes);
352
+ app.route("/api/studio", dateienRoutes);
327
353
  app.route("/api/studio/runtime", runtimeSettingsRoutes);
328
354
  app.route("/api/studio/work", workRoutes);
329
355
  app.route("/api/studio", studio);
330
- app.route("/api/v1", apiRoutes);
331
356
  app.route("/api/local/debug", localDebugRoutes);
332
357
  }
333
358
  app.route("/api/internal", internalRoutes);
@@ -10,6 +10,7 @@ import { discovery, managed, tokenRequest, verifyToken, } from "../manage.js";
10
10
  import { refreshPro } from "../plugins/pro.js";
11
11
  import { requestLang, say } from "../routes/lang.js";
12
12
  import { seal, unseal } from "../secrets/crypto.js";
13
+ import { claimClientInvites } from "../services/client-spaces.js";
13
14
  import { LOCAL_TENANT } from "../tenants/tenant.js";
14
15
  import { finishLink } from "./account.js";
15
16
  import { localTicketExpiry } from "./local-ticket.js";
@@ -400,6 +401,10 @@ export const authRoutes = new Hono()
400
401
  impersonatedBy: admin?.id ?? null,
401
402
  impersonatorEmail: admin?.email ?? null,
402
403
  });
404
+ // A client's first sign-in: the client spaces that invited their address take them in.
405
+ if (claims.role === "client" && !admin) {
406
+ await withTenant(claims.tenantId, () => claimClientInvites(claims.userId, claims.email)).catch((err) => console.error("[clients] claiming invitations:", err));
407
+ }
403
408
  if (state.desktop) {
404
409
  // The session belongs to the app's window, not to this browser.
405
410
  const code = seal({
@@ -154,6 +154,11 @@ export async function spaceAccount(row, connector, who) {
154
154
  return { connector, ctx, label };
155
155
  }
156
156
  /** „Letzte Nutzung“: the connection was just used. */
157
+ /** The rights the provider granted a connection of the space at its sign-in; none for keys. */
158
+ export function grantedScopes(row) {
159
+ const data = row.secret ? unseal(row.secret) : null;
160
+ return data?.scopes ?? [];
161
+ }
157
162
  export async function markUsed(row) {
158
163
  await db
159
164
  .update(schema.spaceConnection)
@@ -220,6 +220,7 @@ export async function brokerCall(call) {
220
220
  whoId: who.id ?? null,
221
221
  runId: where.runId ?? null,
222
222
  stepId: where.stepId ?? null,
223
+ client: where.client ?? null,
223
224
  chatId: where.chatId ?? null,
224
225
  wizardId: where.wizardId ?? null,
225
226
  spaceId: where.spaceId ?? null,
@@ -375,6 +376,7 @@ export async function brokerSecret(call) {
375
376
  whoId: call.who.id ?? null,
376
377
  runId: call.where.runId ?? null,
377
378
  stepId: call.where.stepId ?? null,
379
+ client: call.where.client ?? null,
378
380
  chatId: call.where.chatId ?? null,
379
381
  wizardId: call.where.wizardId ?? null,
380
382
  spaceId: call.where.spaceId ?? null,
@@ -12,6 +12,7 @@ export async function brokerHost(call) {
12
12
  whoId: who.id ?? null,
13
13
  runId: where.runId ?? null,
14
14
  stepId: where.stepId ?? null,
15
+ client: where.client ?? null,
15
16
  chatId: where.chatId ?? null,
16
17
  wizardId: where.wizardId ?? null,
17
18
  spaceId: where.spaceId ?? null,
@@ -1,3 +1,8 @@
1
+ /*
2
+ * The broker: the one path every connector call takes (docs/plans/broker.md). Tools, share
3
+ * targets, plugins and the run's browser import from here; `account.ts` stays the broker's own.
4
+ */
5
+ export { grantedScopes } from "./account.js";
1
6
  export { brokerCall, brokerConnected, brokerSecret, decide, grantBinds, inAudience, kindOf, signInRefused, whereOf, whereOfRun, whoOf, } from "./call.js";
2
7
  export { currentCaller, withCaller } from "./caller.js";
3
8
  export { grantNote, grantOf, hostInGrant, inGrant, runGrant, } from "./grant.js";